package org.ahuanlien.crm.web.controller;

import org.ahuanlien.crm.domain.ClientRepaymentInfo;
import org.ahuanlien.crm.query.ClientRepaymentInfoQueryObject;
import org.ahuanlien.crm.service.IClientRepaymentInfoService;
import org.ahuanlien.crm.util.JSONResult;
import org.ahuanlien.crm.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("clientRepaymentInfo")
public class ClientRepaymentInfoController {

    @Autowired
    private IClientRepaymentInfoService clientRepaymentInfoService;

    @RequestMapping("view")
    public String view() {
        return "clientRepaymentInfo/view";
    }

    @RequestMapping("query")
    @ResponseBody
    public PageResult query(ClientRepaymentInfoQueryObject qo) {
        PageResult result = clientRepaymentInfoService.query(qo);
        return result;
    }



    @RequestMapping("queryByInfoSn")
    @ResponseBody
    public ClientRepaymentInfo  queryByInfoSn(String infoSn) {


        return clientRepaymentInfoService.queryByInfoSn(infoSn);
    }

    @RequestMapping("insert")
    @ResponseBody
    public JSONResult saveOrUpdate(ClientRepaymentInfo clientRepaymentInfo) {
        try {
            clientRepaymentInfoService.insert(clientRepaymentInfo);
        } catch (Exception e) {
            e.printStackTrace();
            return JSONResult.mark("操作失败");
        }
        return JSONResult.success("操作成功");
    }

    @RequestMapping("setOpinion")
    @ResponseBody
    public JSONResult setOpinion(String  opinion , String infoSn) {
        try {
            clientRepaymentInfoService.setOpinion(opinion,infoSn);
        } catch (Exception e) {
            e.printStackTrace();
            return JSONResult.mark("操作失败");
        }
        return JSONResult.success("操作成功");
    }

    @RequestMapping("informClient")
    @ResponseBody
    public JSONResult informClient(String repaymentInfoNumber) {
        try {
            clientRepaymentInfoService.informClient(repaymentInfoNumber);
        } catch (Exception e) {
            e.printStackTrace();
            return JSONResult.mark("操作失败");
        }
        return JSONResult.success("操作成功");
    }

}
